repo.or.cz
/
andmenj-acm.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Namespacing everything to /UVa.
[andmenj-acm.git]
/
UVa
/
305 - Joseph
/
robado305.cpp
blob
6494d5254c02036d760e419ae72555d5aa56e2b7
1
/* Código robado del foro DESPUÉS de haberlo resuelto yo.
2
3
http://acm.uva.es/board/viewtopic.php?t=16135
4
5
*/
6
7
8
9
#include <iostream>
10
using namespace
std
;
11
12
int
main
(
void
)
13
{
14
int
k
;
15
while
((
cin
>>
k
)&&
k
)
16
{
17
int
p
=
k
*
2
;
18
int
m
;
19
for
(
m
=
k
; ;
m
++)
20
{
21
int
x
=
p
;
22
int
y
=(
m
-
1
)%
x
;
23
while
(
y
>=
k
&&
x
>
k
)
24
{
25
x
--;
26
y
= (
y
-
1
+
m
)%
x
;
27
}
28
if
(
x
==
k
)
29
break
;
30
}
31
cout
<<
m
<<
endl
;
32
}
33
}